package com.agileboot.medicine.controller.algorithm;

/**
 * 草药属性相似度计算（欧氏距离）
 */
public class HerbAttributesSimilarityCalculator {

    public static double calculateEuclideanDistance(double[] attributes1, double[] attributes2) {
        double sum = 0.0;

        for (int i = 0; i < attributes1.length; i++) {
            sum += Math.pow(attributes1[i] - attributes2[i], 2);
        }

        return 1 / (1 + Math.sqrt(sum));
    }
}
